package com.goldplusgold.tradedelay.app.trade.dialog;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.goldplusgold.support.lib.base.fragment.FragmentBasicDialog;
import com.goldplusgold.tradedelay.app.R;
import com.goldplusgold.tradedelay.app.trade.activity.ProfitAndLossActivity;

/**
 * Created by admin on 2017/5/27.
 */

public class DeleteWarmTipDialog extends FragmentBasicDialog {

    private String prodCode;
    private String bearBullType;

    public static DeleteWarmTipDialog newInstance(String prodCode, String bearBullType) {

        Bundle args = new Bundle();
        args.putString("prodCode", prodCode);
        args.putString("bearBullType", bearBullType);
        DeleteWarmTipDialog fragment = new DeleteWarmTipDialog();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NO_TITLE, 0);
        Bundle args = getArguments();
        if (args != null) {
            prodCode = args.getString("prodCode");
            bearBullType = args.getString("bearBullType");
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        View view = inflater.inflate(R.layout.fragment_delete_warm_tip, container, false);
        TextView title = (TextView) view.findViewById(R.id.id_text_view_type_warm_tip);
        String content = "当前";
        if (!TextUtils.isEmpty(prodCode)) {
            switch (prodCode) {
                case "Au(T+D)":
                    content = content + "【黄金延期】/";
                    break;
                case "Ag(T+D)":
                    content = content + "【白银延期】/";
                    break;
                case "mAu(T+D)":
                    content = content + "【迷你黄金延期】/";
                    break;
            }
        }
        if (!TextUtils.isEmpty(bearBullType)) {
            switch (bearBullType) {
                case "BEAR":
                    content = content + "【空头】";
                    break;
                case "BULL":
                    content = content + "【多头】";
                    break;
            }
        }
        title.setText(content);
        view.findViewById(R.id.confim_txt).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Activity activity = getActivity();
                if (activity instanceof ProfitAndLossActivity) {
                    ((ProfitAndLossActivity) activity).loadDataAction();
                }
                getDialog().dismiss();
            }
        });
        return view;
    }


}
